/***************************************************************************
 * 文件名：FMEnviromentVariableInfo
 * 功能：
 * 说明：
 * -------------------------------------------------------------------------
 * 创建时间：2025/7/12 15:01:44
 * 创建人：葛浩
 * 邮箱： 2094733071@qq.com
 * =========================================================================
 *
 * 修改人：   
 * 修改时间：   
 * 修改说明：   
 ***************************************************************************/
using DevExpress.XtraEditors;
using System.Windows.Forms;

namespace EnvironmentVariable
{
	public partial class FMEnviromentVariableInfo : XtraForm
	{
		#region Propertys

		/// <summary>
		/// 环境变量
		/// </summary>
		private EnvironmentVariableModel _Info;
		public EnvironmentVariableModel EnvironmentVariableModel
		{
			get { return _Info; }
			set { _Info = value; }
		}

		#endregion

		public FMEnviromentVariableInfo(EnvironmentVariableModel info)
		{
			InitializeComponent();
			_Info = info;
		}

		/// <summary>
		/// Load事件
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void FMEnviromentVariableInfo_Load(object sender, System.EventArgs e)
		{
			txtVariableName.Text = _Info?.VariableName;
			txtVariableValue.Text = _Info?.VariableValue;
		}

		/// <summary>
		/// 确认
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnConfirm_Click(object sender, System.EventArgs e)
		{
			if (string.IsNullOrEmpty(txtVariableName.Text))
			{
				MessageBox.Show("环境变量名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			if (string.IsNullOrEmpty(txtVariableValue.Text))
			{
				MessageBox.Show("环境变量值不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			_Info.VariableName = txtVariableName.Text.Trim();
			_Info.VariableValue = txtVariableValue.Text.Trim();

			DialogResult = System.Windows.Forms.DialogResult.OK;
		}

		/// <summary>
		/// 取消
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			DialogResult = System.Windows.Forms.DialogResult.Cancel;
		}

	}
}
